/**********************************************************************************************/
/* VSQL_QueryResult.h                                    	                 				  */
/*                                                                       					  */
/* Copyright Paradigma, 1993-2006															  */
/* All Rights Reserved                                                   					  */
/**********************************************************************************************/

#ifndef _VSQL_QueryResult_h 
	#define _VSQL_QueryResult_h
#pragma once

#include <VShared/VSQL/Interfaces/VSQL_I_SqlDatabase.h>
#include <VShared/VSQL/Interfaces/VSQL_I_Cursor.h>

// FINAL:
#include <VShared/FBL/publ/Headers/FBL_pre_header.h>


/**********************************************************************************************/
VSQL_Begin_Namespace


/**********************************************************************************************/
// THIS module declarations:
//
SMART_CLASS(QueryResult);


/**********************************************************************************************/
// Specifies the cursor location. 
//
enum EQueryType
{
	kUnknown = 0,
	kCursor = 1,		///< Cursor result
	kBoolean,
	kULong,				///< Affected rows result
	kString				///< String result.
};


/**********************************************************************************************/
enum EQueryFlags
{
	kNone					= 0,		// (r/w) There is no any flags.	
	kSchemaWasModified		= 1 << 0,   // (r/w) The schema was modified by the query.
	kDatabaseWasChanged		= 1 << 1,   // (r/w) The database was changed by the query.
	kXMLResult				= 1 << 2    // (r/w) Query contains result as XML. (For future use)
};


/**********************************************************************************************/
// This class is for Database::SqlQuery() method result.
// 
class FBL_SHARED_EXP_CLASS QueryResult : public I_Unknown
{	
 		IMPLEMENT_SINGLE_UNKNOWN( QueryResult )
 
	public://///////////////////////////////////////////////////////////////////////////////////
	
							QueryResult( void );
							QueryResult( const QueryResult& inQueryResult );

virtual						~QueryResult( void );

	
	public://///////////////////////////////////////////////////////////////////////////////////

		EQueryType			get_Type( void ) const throw();
		
		EQueryFlags			get_Flags() const throw();

		void				SetFlags( EQueryFlags inFlag );

			// <Cursor>	
			
		I_Cursor_Ptr		get_AsCursor( void ) const throw();
		void				put_AsCursor( I_Cursor_Ptr	inpCursor ) throw();		

			// <Boolean>	
			
		bool				get_AsBoolean( void ) const throw();
		void				put_AsBoolean( bool	inValue ) throw();		

			// <ULong>	
			
		ulong				get_AsULong( void ) const throw();
		void				put_AsULong( ulong inValue ) throw();
				
			// <String>
		const String*		get_AsString( void ) const throw();

							// pass ownership of inpValue to QueryReult!
		void				put_AsString( String* inpValue ) throw();
		
							// Create new String object and copy inValue string.
		void				put_AsString( const String&	inValue ) throw();


			// <Explaination>

		const String*		get_Explanation( void ) const throw(); 	
		
							// pass ownership of inExplainStr to QueryResult!
		void				put_Explanation( String* inExplainStr );


	protected://////////////////////////////////////////////////////////////////////////////////

	// Result type:

		EQueryType			mResultType;
		EQueryFlags			mFlags;

	// Result data:

		I_Cursor_Ptr		mpCursor;
		bool				mBoolValue;
		ulong				mUlongValue;
		String*				mpStringValue;
		
	// Explaination of result:
		
		String*				mpExplainStr;	// xml format.
};


/**********************************************************************************************/
VSQL_End_Namespace

#include <VShared/FBL/publ/Headers/FBL_post_header.h>

#endif // _VSQL_QueryResult_h